package top.haijunit.work.modules.repo.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.haijunit.work.core.doamin.TreeNode;
import top.haijunit.work.modules.core.WorkConstant;
import top.haijunit.work.modules.core.enums.StatusEnum;

/**
 * 部门信息
 *
 * @author zhanghaijun
 * @since 2024-08-27
 */
@Data
@Schema(description = "部门信息")
@JsonIgnoreProperties({"id", "parentId"})
public class DeptInfo extends TreeNode<DeptInfo, Long> {

    /**
     * 部门id
     */
    @Schema(description = "部门code", example = WorkConstant.DEFAULT_ID_STR)
    @ExcelProperty(value = "部门code")
    private Long deptCode;

    /**
     * 父级部门code
     */
    @Schema(description = "父级部门code", example = "0")
    @NotNull(message = "父级部门code不能为空")
    @ExcelProperty(value = "父级部门code")
    private Long parentCode;

    /**
     * 部门名称
     */
    @Schema(description = "部门名称", example = "研发部")
    @NotBlank(message = "部门名称不能为空")
    @Length(max = 64, message = "部门名称长度不能超过{max}个字符")
    @ExcelProperty(value = "部门名称")
    private String deptName;
    /**
     * 部门别名
     */
    @Schema(description = "部门别名", example = "R&D")
    @NotBlank(message = "简称不能为空")
    @Length(max = 64, message = "简称长度不能超过{max}个字符")
    @ExcelProperty(value = "部门别名")
    private String nickname;
    /**
     * 部门描述信息
     */
    @Schema(description = "部门描述信息", example = "负责公司产品研发")
    @NotBlank(message = "部门描述信息不能为空")
    @Size(max = 256, message = "部门描述信息长度不能超过{max}个字符")
    @ExcelProperty(value = "部门描述信息")
    private String remarks;
    /**
     * 部门等级
     */
    @Schema(description = "部门等级", example = "2")
    @Min(value = 1, message = "部门等级不能小于{value}")
    @ExcelProperty(value = "部门等级")
    private Integer deptLevel;
    /**
     * 部门状态
     */
    @Schema(description = "部门状态", defaultValue = "1", example = "1")
    @ExcelProperty(value = "部门状态")
    private StatusEnum statusCode;

    @Override
    public Long getId() {
        return this.getDeptCode();
    }

    @Override
    public Long getParentId() {
        return this.getParentCode();
    }
}
